package com.neusoft.ysu.npms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.ysu.npms.mapper.ApplypoorMapper;
import com.neusoft.ysu.npms.mapper.ApprovalMapper;
import com.neusoft.ysu.npms.mapper.FarmerMapper;
import com.neusoft.ysu.npms.mapper.RiskMapper;
import com.neusoft.ysu.npms.pojo.Approval;
import com.neusoft.ysu.npms.pojo.ApprovalInfo;
import com.neusoft.ysu.npms.pojo.DepartmentInfo;
import com.neusoft.ysu.npms.pojo.Result;
import com.neusoft.ysu.npms.service.IApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者：刘金秋
 * @since 2024-06-18
 */
@Service
public class ApprovalServiceImpl extends ServiceImpl<ApprovalMapper, Approval> implements IApprovalService {

    @Autowired
    ApprovalMapper approvalMapper;
    @Autowired
    ApplypoorMapper applypoorMapper;
    @Autowired
    RiskMapper riskMapper;
    @Autowired
    FarmerMapper farmerMapper;
    @Override
    public Result add(Approval approval) {
        return new Result<>(0, "", approvalMapper.add(approval));

    }

    @Override
    public Result deleteApproval(Approval approval) {
        return new Result<>(0,"",approvalMapper.deleteApproval(approval));
    }

    @Override
    public Result updateApproval(Approval approval) {
        return new Result<>(0,"",approvalMapper.updateApproval(approval));
    }

    @Override
    public Result selectAll() {
        return new Result<>(0,"",approvalMapper.selectAll());
    }

    @Override
    public Result findById(Approval approval) {
        return new Result<>(0,"",approvalMapper.findById(approval));
    }
    @Override
    public PageInfo getvillagelist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.getvillagelist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public PageInfo gettownlist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.gettownlist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public PageInfo getcountylist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.getcountylist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public PageInfo getcitylist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.getcitylist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public PageInfo getprovincelist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.getprovincelist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public PageInfo getbacklist(ApprovalInfo approvalInfo, int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<ApprovalInfo> infos=approvalMapper.getbacklist(approvalInfo);
        return new PageInfo(infos);
    }
    @Override
    public Result applysuccess(ApprovalInfo approvalInfo) {
        return new Result<>(0, "", approvalMapper.applysuccess(approvalInfo));
    }
    @Override
    public Result applyfail(ApprovalInfo approvalInfo){
        return new Result<>(0,"",approvalMapper.applyfail(approvalInfo));
    }
    @Override
    public Result logout(ApprovalInfo approvalInfo){
        approvalMapper.logout(approvalInfo);
        applypoorMapper.logout1(approvalInfo);
        riskMapper.logout2(approvalInfo);
        farmerMapper.logout3(approvalInfo);
        return new Result<>(0,"",null);
    }
}
